﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lg.Core.Form.Types
{
    public class DateRange:BaseType,IType
    {
        /// <summary>
        /// datetime类型的formatstring ,标准ISO
        /// </summary>
        public string? DateFormat { get; set; }
        /// <summary>
        /// 日期取值范围，分割符"~"
        /// </summary>
        public List<DateTime?>? Range { get; set; }


        public void Verify()
        {
            if (this.IsRender)
            {
                if (Required)
                {
                    Validate.Required(Value, $"字段:{Title},不可为空！");
                }
                Validate.DataRange(Value, Range, $"字段：{Title}不是有效的日期格式！");
            }

        }

        public void GetSaveDbValue(Dictionary<string, dynamic> formData, string inputValue)
        {
            formData.Add(Name, inputValue);
        }
    }
}
